home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
t3_1
/
risc_src.lha
/
risc_sources
/
xlib
/
hello.t
< prev
next >
Wrap
Text File
|
1990-06-04
|
2KB
|
54 lines
;;; Hello, World example from Oliver Jones' book in Scheme->C
(herald hello)
(define (HELLO-WORLD displayname)
(let* ((hello "Hello, World")
(hi "Hi!")
(dpy (let ((x (xopendisplay displayname)))
(if (null-pointer? x)
(error "DISPLAY is not defined"))
x))
(screen (xdefaultscreen dpy))
(background (xwhitepixel dpy screen))
(foreground (xblackpixel dpy screen))
(window (xcreatesimplewindow dpy (xdefaultrootwindow dpy)
200 300 350 250 5 foreground background))
(gctxt (xcreategc dpy window 0 (make-xgcvalues)))
(event (make-xevent)))
(xstorename dpy window
"Hello, World in Scheme->C using X11's Xlib")
(xseticonname dpy window "hello")
(xsetbackground dpy gctxt background)
(xsetforeground dpy gctxt foreground)
(xselectinput dpy window
(fixnum-logior buttonpressmask
(fixnum-logior keypressmask exposuremask)))
(xmapraised dpy window)
(iterate loop ()
(ynextevent dpy event)
(cond ((eq? (xevent-type event) expose) (gc)
(xdrawimagestring (xevent-xexpose-display event)
(xevent-xexpose-window event) gctxt 50 50
hello (string-length hello))
(loop))
((eq? (xevent-type event) mappingnotify)
(xrefreshkeyboardmapping event)
(loop))
((eq? (xevent-type event) buttonpress)
(xdrawimagestring (xevent-xbutton-display event)
(xevent-xbutton-window event) gctxt
(xevent-xbutton-x event) (xevent-xbutton-y event)
hi (string-length hi))
(loop))
((and (eq? (xevent-type event) keypress)
(equal? (ylookupstring event) "q"))
(xfreegc dpy gctxt)
(xdestroywindow dpy window)
(xclosedisplay dpy))
(else (loop))))))